package cn.netjava.wk;

import java.io.File;
import java.io.FileNotFoundException;

public class FileSearchThread {
 static int searchfailure=0;
 String filename;
 File[]path=File.listRoots();
 public FileSearchThread(String filename){	 
	 this.filename=filename;
     search();
 }
/*
 * @param no vulues
 * @param this mehtod use to create some FileSearch object
 *@param it can just the search success or failure
 * @return null
 */
 public void search(){
	FileSearch[]file=new FileSearch[path.length];    
	for(int j=0;j<file.length;j++){
    	 file[j]=new FileSearch(path[j].getAbsolutePath(),filename);
        file[j].setPriority(8);
    	 file[j].start();
	}    
	try {
		SearchMonitor mm=new SearchMonitor("D:\\pp\\searchfile.txt",file);
	    mm.setPriority(3);
	} catch (FileNotFoundException e) {
		
		e.printStackTrace();
	}
	if(FileSearchThread.searchfailure==(file.length-1)){
    	//if all search is failure
    	System.out.println("This file "+filename+"can not search!");
   }
}
public static void main(String[]args){
	FileSearchThread ff=new FileSearchThread(".java");
}
}
